From: Florian Müllner Date: Mon, 16 Dec 2024 13:21:18 +0000 (+0100) Subject: popupMenu: Expose SwitchItem state as GObject property X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~177^2^2~9 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=64fea97d9b28f7ad32fdbe34219e8bf24f58f400;p=gnome-shell.git popupMenu: Expose SwitchItem state as GObject property This will allow using bindings instead of explicit signal connections. Part-of: (cherry picked from commit 296e5c32e4470b7026c4e08affeeaec9eb80aa52) --- diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index efc7e464f..72e2b278a 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -531,6 +531,12 @@ export const Switch = GObject.registerClass({ }); export const PopupSwitchMenuItem = GObject.registerClass({ + Properties: { + 'state': GObject.ParamSpec.boolean( + 'state', null, null, + GObject.ParamFlags.READWRITE, + false), + }, Signals: {'toggled': {param_types: [GObject.TYPE_BOOLEAN]}}, }, class PopupSwitchMenuItem extends PopupBaseMenuItem { _init(text, active, params) { @@ -602,12 +608,20 @@ export const PopupSwitchMenuItem = GObject.registerClass({ return this._switch.state; } + set state(state) { + if (this._switch.state === state) + return; + + this._switch.set({state}); + } + setToggleState(state) { - this._switch.state = state; + this.set({state}); } _onToggled() { this.emit('toggled', this._switch.state); + this.notify('state'); this._checkAccessibleState(); }